//
// CVegetableManager.java
// Copyright (C) 2010  "Naush" <naush _ hotmail _ fr>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>./* ----------------------------------------------------------------------------







package org.ryzom.nel.threed;

import org.ryzom.nel.misc.CRGBA;
import org.ryzom.nel.misc.CRGBAF;
import org.ryzom.nel.misc.CVector;

public class CVegetableManager {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  public CVegetableManager(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  public static long getCPtr(CVegetableManager obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nel3dJNI.delete_CVegetableManager(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public CVegetableManager(long maxVertexVbHardUnlit, long maxVertexVbHardLighted, long nbBlendLayers, float blendLayerDistMax) {
    this(nel3dJNI.new_CVegetableManager__SWIG_0(maxVertexVbHardUnlit, maxVertexVbHardLighted, nbBlendLayers, blendLayerDistMax), true);
  }

  public CVegetableManager(long maxVertexVbHardUnlit, long maxVertexVbHardLighted, long nbBlendLayers) {
    this(nel3dJNI.new_CVegetableManager__SWIG_1(maxVertexVbHardUnlit, maxVertexVbHardLighted, nbBlendLayers), true);
  }

  public CVegetableManager(long maxVertexVbHardUnlit, long maxVertexVbHardLighted) {
    this(nel3dJNI.new_CVegetableManager__SWIG_2(maxVertexVbHardUnlit, maxVertexVbHardLighted), true);
  }

  public void createVegetableBlendLayersModels(CScene scene) {
    nel3dJNI.CVegetableManager_createVegetableBlendLayersModels(swigCPtr, this, CScene.getCPtr(scene), scene);
  }

  public CVegetableShape getVegetableShape(String shape) {
    long cPtr = nel3dJNI.CVegetableManager_getVegetableShape(swigCPtr, this, shape);
    return (cPtr == 0) ? null : new CVegetableShape(cPtr, false);
  }

  public CVegetableClipBlock createClipBlock() {
    long cPtr = nel3dJNI.CVegetableManager_createClipBlock(swigCPtr, this);
    return (cPtr == 0) ? null : new CVegetableClipBlock(cPtr, false);
  }

  public void deleteClipBlock(CVegetableClipBlock clipBlock) {
    nel3dJNI.CVegetableManager_deleteClipBlock(swigCPtr, this, CVegetableClipBlock.getCPtr(clipBlock), clipBlock);
  }

  public CVegetableSortBlock createSortBlock(CVegetableClipBlock clipBlock, CVector center, float radius) {
    long cPtr = nel3dJNI.CVegetableManager_createSortBlock(swigCPtr, this, CVegetableClipBlock.getCPtr(clipBlock), clipBlock, CVector.getCPtr(center), center, radius);
    return (cPtr == 0) ? null : new CVegetableSortBlock(cPtr, false);
  }

  public void deleteSortBlock(CVegetableSortBlock sortBlock) {
    nel3dJNI.CVegetableManager_deleteSortBlock(swigCPtr, this, CVegetableSortBlock.getCPtr(sortBlock), sortBlock);
  }

  public CVegetableInstanceGroup createIg(CVegetableSortBlock sortBlock) {
    long cPtr = nel3dJNI.CVegetableManager_createIg(swigCPtr, this, CVegetableSortBlock.getCPtr(sortBlock), sortBlock);
    return (cPtr == 0) ? null : new CVegetableInstanceGroup(cPtr, false);
  }

  public void deleteIg(CVegetableInstanceGroup ig) {
    nel3dJNI.CVegetableManager_deleteIg(swigCPtr, this, CVegetableInstanceGroup.getCPtr(ig), ig);
  }

  public void reserveIgAddInstances(CVegetableInstanceGroupReserve vegetIgReserve, CVegetableShape shape, CVegetableManager.TVegetableWater vegetWaterState, long numInstances) {
    nel3dJNI.CVegetableManager_reserveIgAddInstances(swigCPtr, this, CVegetableInstanceGroupReserve.getCPtr(vegetIgReserve), vegetIgReserve, CVegetableShape.getCPtr(shape), shape, vegetWaterState.swigValue(), numInstances);
  }

  public void reserveIgCompile(CVegetableInstanceGroup ig, CVegetableInstanceGroupReserve vegetIgReserve) {
    nel3dJNI.CVegetableManager_reserveIgCompile(swigCPtr, this, CVegetableInstanceGroup.getCPtr(ig), ig, CVegetableInstanceGroupReserve.getCPtr(vegetIgReserve), vegetIgReserve);
  }

  public void addInstance(CVegetableInstanceGroup ig, CVegetableShape shape, SWIGTYPE_p_NLMISC__CMatrix mat, CRGBAF ambientColor, CRGBAF diffuseColor, float bendFactor, float bendPhase, float bendFreqFactor, float blendDistMax, CVegetableManager.TVegetableWater vegetWaterState, CVegetableUV8 dlmUV) {
    nel3dJNI.CVegetableManager_addInstance(swigCPtr, this, CVegetableInstanceGroup.getCPtr(ig), ig, CVegetableShape.getCPtr(shape), shape, SWIGTYPE_p_NLMISC__CMatrix.getCPtr(mat), CRGBAF.getCPtr(ambientColor), ambientColor, CRGBAF.getCPtr(diffuseColor), diffuseColor, bendFactor, bendPhase, bendFreqFactor, blendDistMax, vegetWaterState.swigValue(), CVegetableUV8.getCPtr(dlmUV), dlmUV);
  }

  public void setGlobalDensity(float density) {
    nel3dJNI.CVegetableManager_setGlobalDensity(swigCPtr, this, density);
  }

  public float getGlobalDensity() {
    return nel3dJNI.CVegetableManager_getGlobalDensity(swigCPtr, this);
  }

  public void updateDriver(IDriver driver) {
    nel3dJNI.CVegetableManager_updateDriver(swigCPtr, this, IDriver.getCPtr(driver), driver);
  }

  public void loadTexture(String texName) {
    nel3dJNI.CVegetableManager_loadTexture__SWIG_0(swigCPtr, this, texName);
  }

  public void loadTexture(ITexture itex) {
    nel3dJNI.CVegetableManager_loadTexture__SWIG_1(swigCPtr, this, ITexture.getCPtr(itex), itex);
  }

  public void setDirectionalLight(CRGBA ambient, CRGBA diffuse, CVector light) {
    nel3dJNI.CVegetableManager_setDirectionalLight(swigCPtr, this, CRGBA.getCPtr(ambient), ambient, CRGBA.getCPtr(diffuse), diffuse, CVector.getCPtr(light), light);
  }

  public void lockBuffers() {
    nel3dJNI.CVegetableManager_lockBuffers(swigCPtr, this);
  }

  public void unlockBuffers() {
    nel3dJNI.CVegetableManager_unlockBuffers(swigCPtr, this);
  }

  public void render(CVector viewCenter, CVector frontVector, SWIGTYPE_p_std__vectorT_NLMISC__CPlane_t pyramid, ITexture textureDLM, IDriver driver) {
    nel3dJNI.CVegetableManager_render(swigCPtr, this, CVector.getCPtr(viewCenter), viewCenter, CVector.getCPtr(frontVector), frontVector, SWIGTYPE_p_std__vectorT_NLMISC__CPlane_t.getCPtr(pyramid), ITexture.getCPtr(textureDLM), textureDLM, IDriver.getCPtr(driver), driver);
  }

  public void setWind(CVector windDir, float windFreq, float windPower, float windBendMin) {
    nel3dJNI.CVegetableManager_setWind(swigCPtr, this, CVector.getCPtr(windDir), windDir, windFreq, windPower, windBendMin);
  }

  public void setTime(double time) {
    nel3dJNI.CVegetableManager_setTime(swigCPtr, this, time);
  }

  public void setUpdateLightingTime(double time) {
    nel3dJNI.CVegetableManager_setUpdateLightingTime(swigCPtr, this, time);
  }

  public void updateLighting() {
    nel3dJNI.CVegetableManager_updateLighting(swigCPtr, this);
  }

  public void setUpdateLightingFrequency(float freq) {
    nel3dJNI.CVegetableManager_setUpdateLightingFrequency(swigCPtr, this, freq);
  }

  public void updateLightingAll() {
    nel3dJNI.CVegetableManager_updateLightingAll(swigCPtr, this);
  }

  public void resetNumVegetableFaceRendered() {
    nel3dJNI.CVegetableManager_resetNumVegetableFaceRendered(swigCPtr, this);
  }

  public long getNumVegetableFaceRendered() {
    return nel3dJNI.CVegetableManager_getNumVegetableFaceRendered(swigCPtr, this);
  }

  public final static class TVegetableWater {
    public final static TVegetableWater AboveWater = new TVegetableWater("AboveWater", nel3dJNI.CVegetableManager_AboveWater_get());
    public final static TVegetableWater UnderWater = new TVegetableWater("UnderWater");
    public final static TVegetableWater IntersectWater = new TVegetableWater("IntersectWater");
    public final static TVegetableWater VegetInfoLast = new TVegetableWater("VegetInfoLast");

    public final int swigValue() {
      return swigValue;
    }

    public String toString() {
      return swigName;
    }

    public static TVegetableWater swigToEnum(int swigValue) {
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (int i = 0; i < swigValues.length; i++)
        if (swigValues[i].swigValue == swigValue)
          return swigValues[i];
      throw new IllegalArgumentException("No enum " + TVegetableWater.class + " with value " + swigValue);
    }

    private TVegetableWater(String swigName) {
      this.swigName = swigName;
      this.swigValue = swigNext++;
    }

    private TVegetableWater(String swigName, int swigValue) {
      this.swigName = swigName;
      this.swigValue = swigValue;
      swigNext = swigValue+1;
    }

    private TVegetableWater(String swigName, TVegetableWater swigEnum) {
      this.swigName = swigName;
      this.swigValue = swigEnum.swigValue;
      swigNext = this.swigValue+1;
    }

    private static TVegetableWater[] swigValues = { AboveWater, UnderWater, IntersectWater, VegetInfoLast };
    private static int swigNext = 0;
    private final int swigValue;
    private final String swigName;
  }

}
